package com.czkt.controller;


import com.czkt.service.IOrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Controller
public class RortController {


    @Autowired
    IOrdersService ordersService;

    @RequestMapping("/contrRpt/list")
    public Object contrRptList(Model model){

      List<HashMap> orderList=  ordersService.getOrderMapList();

        List<Object> customerName = orderList.stream().map(order->{
            return order.get("odr_customer");
        }).collect(Collectors.toList());

        List<Object> orderAmount = orderList.stream().map(order->{
            return order.get("orderAmount");
        }).collect(Collectors.toList());
//        customerName[0]="方正集团";
//        customerName[1]="聪海信息科技有限公司";
//        customerName[2]="客户3";
//        customerName[3]="客户4";
//        customerName[4]="2";

        model.addAttribute("custmoers",customerName);
//        double[] orderAmount = new double[5];
//        orderAmount[0]=1000d;
//        orderAmount[1]=1100d;
//        orderAmount[2]=100d;
//        orderAmount[3]=50d;
//        orderAmount[4]=5000d;

        model.addAttribute("orderAmounts",orderAmount);

        return "contrRpt/list";
    }
}
